<template>
  <div element-loading-text="数据加载中..." v-loading.fullscreen.lock="loadingShow">
    <el-button type="success" @click="addTestPaperClick()">添加试卷</el-button>
    <el-dialog v-model="dialogVisible" title="试卷添加" width="30%" @close="closeDislogVidble()" :close-on-click-modal="false" destroy-on-close
               center>

            <div style="height: 300px">
                <span>
                  <div>
                    <el-steps :active="active" finish-status="success" :align-center="true">
                        <el-step title="试卷信息" />
                        <el-step title="试卷科目类型" />
                        <el-step title="试卷题目" />
                      </el-steps>
                  </div>
                      <el-divider />
                      <div v-if="active===0">
                        <el-form>
                          <el-form-item label="" label-width="">
                            <div>试卷标题</div>
                              <el-input
                                  v-model="inputData.testPaperName"
                                  :rows="2"
                                  type="textarea"
                                  placeholder="请输入....."
                                  maxlength="400"
                                  show-word-limit
                              />
                          </el-form-item>
                        </el-form>
                        <div style="height:10px"/>

                        <el-form >
                              <el-form-item label="" label-width="">
      <!--                          <el-space :size="0">-->
                                  <el-input v-model.number="inputData.testPaperFraction" placeholder="请输入分数..." style="width:250px" >
                                    <template #prepend >
                                      <span style="width: 50px">
                                        分数
                                      </span>
                                    </template>
                                  </el-input>
                                  <el-input v-model.number="inputData.testPaperTimeNumber" style="width:250px">
                                    <template #prepend >
                                      <span style="width: 50px">
                                        考试时间
                                      </span>
                                    </template>
                                  </el-input>
                                  <el-input v-model="nowTime" style="width:300px" :disabled="true">
                                    <template  #prepend>
                                      <span style="width: 50px">
                                        创建时间
                                      </span>
                                    </template>
                                  </el-input>
                                <!--                          </el-space>-->

                              </el-form-item>
                              <div style="height:10px"/>


                                 <el-form-item label="" label-width="">
                                    <el-select v-model="inputData.testPaperDifficulty" style="width:250px">
                                      <el-option label="请选择难度" :value="0"/>
                                      <el-option :label="item" :value="item" v-for="item in [1,2,3,4,5]" :key="item">
                                      </el-option>
                                    </el-select>
                                   <el-select v-model="inputData.testPaperTypeId" style="width:250px">
                                     <el-option label="请选择试卷类型" :value="0"/>
                                      <el-option :label="item.testPaperTypeName" :value="item.testPaperTypeId" v-for="item in store.state.questionBank.subjectModel.testPaperTypeList" :key="item.testPaperTypeId">
                                      </el-option>
                                    </el-select>
                                  </el-form-item>
                            </el-form>
                      </div>

                  <!--          第二个页面        -->
                      <div v-if="active===1">
                        <el-descriptions class="margin-top" title="选择的类型" :column="1" border>
                          <el-descriptions-item>
                            <template #label>
                              <div style="width: 50px">类型</div>
                            </template>
                            <span v-for="item in selectArr" :key="item">{{item+" > "}}</span>
                          </el-descriptions-item>
                        </el-descriptions>
                        <el-scrollbar height="150px">
                          <TreeCommponent v-if="oneTableData != null" :treeData="oneTableData" @treeComponent="treeComponent" :defaultExpandAll="true" :showCheckBox="false"></TreeCommponent>
                        </el-scrollbar>
                      </div>
                  <!--         第三个页面         -->
                      <div v-if="active===2">
<!--                          <el-row class="row-bg" justify="space-between">
                              <el-col :span="24">
                                  <el-button @click="autoSelectSubjectClick()">一键选题</el-button>
                                <el-button @click="manualSelectSubjectClick()">手动选题</el-button>
                              </el-col>
                          </el-row>-->
                          <el-tabs type="border-card" v-model="tabsNumber" @tab-click="tabClick">
                            <el-tab-pane label="一键选题" name="one">
                              <!--   一键按钮的显示div-->
                              <div>
                                <span>请输入各个题型要生成的数量</span>
                                <el-row>
                                  <el-col :span="8">
                                    <span>单选题</span>
                                    <el-input-number v-model="autoDataSubject.oneSelectSubjectNumber" :min="1" :max="100" />

                                  </el-col>
                                  <el-col :span="8">
                                    <span>判断题</span>
                                    <el-input-number v-model="autoDataSubject.isSelectSubjectNumber" :min="1" :max="100" />
                                  </el-col>
                                  <el-col :span="8">
                                    <span>多选题</span>
                                    <el-input-number v-model="autoDataSubject.machSelectSubjectNumber" :min="1" :max="100" />
                                  </el-col>
                                </el-row>
                                    <!--                            <el-row>
                                                                    <el-button @click="readlyProduction()">点击生成</el-button>
                                                            </el-row>-->
                          </div>
                            </el-tab-pane>
                            <el-tab-pane label="手动选题" @click="manualSelectSubjectClick()" name="two">
                              <!--  手动选择div-->
                              <div>
                                <el-space size="large" alignment>
                                  <el-badge :value="userSelectSubject.filter(v=>v.subjectTypeId == 1).length" class="item">
                                    <el-button link>选择题</el-button>
                                  </el-badge>
                                  <el-badge :value="userSelectSubject.filter(v=>v.subjectTypeId == 2).length" class="item">
                                    <el-button link>判断题</el-button>
                                  </el-badge>
                                  <el-badge :value="userSelectSubject.filter(v=>v.subjectTypeId == 3).length" class="item">
                                    <el-button link>多选题</el-button>
                                  </el-badge>
                                </el-space>

                              </div>
                            </el-tab-pane>
                          </el-tabs>





                      </div>
                  <!--         手动添加题目的弹出层         -->
                  <div>
                    <el-dialog v-model="dialogVisibleShow" title="选题" width="70%" @close="dialogVisibleClose()" center :close-on-click-modal="false">
                    <div>
                      <el-space wrap size="large">
                          <el-select v-model="pageData.subjectTypeId" @change="selectSubjectTypeChange()">
                            <el-option :value="0" label="全部"></el-option>
                            <el-option :value="1" label="单选题"></el-option>
                            <el-option :value="2" label="判断题"></el-option>
                            <el-option :value="3" label="多选题"></el-option>
                          </el-select>
                          <el-badge :value="userSelectSubject.filter(v=>v.subjectTypeId == 1).length" class="item">
                            <el-button @click="openUserSelectSubjectDig(1)">点击查看已选的选择题</el-button>
                          </el-badge>
                          <el-badge :value="userSelectSubject.filter(v=>v.subjectTypeId == 2).length" class="item">
                            <el-button @click="openUserSelectSubjectDig(2)">点击查看已选的判断题</el-button>
                          </el-badge>
                          <el-badge :value="userSelectSubject.filter(v=>v.subjectTypeId == 3).length" class="item">
                            <el-button @click="openUserSelectSubjectDig(3)">点击查看已选的多选题</el-button>
                          </el-badge>
                      </el-space>

                    </div>

                    <el-divider />
                    <div>
                      <el-table :data="subjectTableData" height="500" style="width: 100%">
                        <el-table-column type="index" width="50" />
                        <el-table-column label="题目" prop="subjectTitle" width="auto"/>
                        <el-table-column label="操作" align="right">
                          <template #default="scorp">
                            <el-button link type="success" @click="userSelectClick(scorp.row)">添加</el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                      <el-pagination
                          v-model:currentPage="pageData.currentPage4"
                          v-model:page-size="pageData.pageSize4"
                          :page-sizes="[10, 20, 50, 100]"
                          layout=" prev, pager, next, jumper,sizes,total"
                          :total="pageData.subjectDataNumber"
                          @size-change="handleSizeChange"
                          @current-change="handleCurrentChange"
                      />
                    </div>
                     <template #footer>
                        <el-button @click="confirmSelectedSubject()" :disabled="userSelectSubject.length <= 0">确定</el-button>
                      </template>
                  </el-dialog>
                    <el-dialog v-model="dialogVisibleUserSelectSubjectShow" title="选题" width="50%" @close="dialogVisibleUserSelectSubjectClose()" center :close-on-click-modal="false">
                      <div>
                        <el-table :data="userSelectSubjectTableData" height="500" style="width: 100%">
                          <el-table-column type="index" width="50" />
                          <el-table-column label="题目" prop="subjectTitle" width="auto"/>
                          <el-table-column label="操作" align="right">
                            <template #default="scorp">
                              <el-button link type="danger" @click="userDelClick(scorp.row)">移除</el-button>
                            </template>
                          </el-table-column>
                        </el-table>
                      </div>
                      <template #footer>
                        <el-button @click="dialogVisibleUserSelectSubjectClose()">关闭</el-button>
                      </template>
                  </el-dialog>
                  </div>

                </span>
              </div>

        <template #footer>

          <el-button-group>

            <el-button type="primary" @click="back()" :disabled="active === 0" >上一步</el-button>
<!--            <el-tooltip
                class="box-item"
                effect="dark"
                :content="stringshow"
                placement="bottom"
            >-->
            <el-button type="primary" @click="next()" :disabled="buttonIsOpen">下一步</el-button>
<!--            </el-tooltip>-->
          </el-button-group>
        </template>
    </el-dialog>
  </div>
</template>

<script>
import {reactive, ref} from "vue";
import { computed, watch } from '@vue/runtime-core'
import {useStore} from "vuex";
import TreeCommponent from "@/components/LeEn_questionBank/ReuseComponent/TreeCommponent";
import  {ElMessageBox,ElMessage,ElNotification} from "element-plus";
import axios from "axios";

export default {
  name: "MyAddTestPaperComponent",
  components: {TreeCommponent},
  setup(){
    const {ArrowLeft,ArrowRight} = require('@element-plus/icons-vue');
    const store = new useStore()
    let inputData = reactive({
        testPaperName:'',
        testPaperFraction:0,
        testPaperTimeNumber:0,
        testPaperDifficulty:0,
        testPaperTypeId:0,
        accountTypeId:0,
    })
    //初始化方法
    function into(){
          inputData.testPaperName=''
          inputData.testPaperFraction=0
          inputData.testPaperTimeNumber=0
          inputData.testPaperDifficulty=0
          inputData.testPaperTypeId=0
          inputData.accountTypeId=0
          autoDataSubject.oneSelectSubjectNumber=0//单选题的数量
          autoDataSubject.isSelectSubjectNumber=0//判断题数量
          autoDataSubject.machSelectSubjectNumber=0//多选题数量
          selectArr.value = []
          active.value = 0
           buttonIsOpen.value = true
            stringshow.value =""
    }
    //树
    let oneTableData = ref()
    //let selectTreeData = ref(null)
    let selectArr = ref([])
    //点击选择的
    function treeComponent(a){
        if(!a.level){
          inputData.accountTypeId = a.industryId

          selectArr.value = getAccountTypeList(store.state.questionBank.subjectModel.subjectTypeTreeData,a.industryId)
        }else{

          selectArr.value = []
          inputData.accountTypeId = 0
        }
    }
    let nowTime = new Date().toLocaleString()
    //弹出层开关
    let dialogVisible = ref(false)
    //步骤条
    let active = ref(0)
    //打开弹出层
    function addTestPaperClick(){
      into()
      oneTableData.value = store.state.questionBank.subjectModel.subjectTypeTreeData
      dialogVisible.value = true
    }
    //关闭弹出层
    function closeDislogVidble(){
      dialogVisible.value = false
    }
    //上一步
    function back(){
      buttonIsOpen.value = false
      if(active.value === 2){
        userSelectSubject.value = []
        userSelectSubjectId.value = []

      }
      active.value = active.value -1

    }
    //下一步
    function next(){
      active.value = active.value +1
      //console.log(active.value)
            if(active.value === 1){
              if(inputData.accountTypeId === 0){
                buttonIsOpen.value = true
                stringshow.value = "请必须选择"
              }else{
                buttonIsOpen.value = false
              }

            }else if(active.value === 3){
              buttonIsOpen.value = true
              if(tabsNumber.value === "one"){
                ElMessageBox.confirm(
                    '确认添加?',
                    'Warning',
                    {
                      confirmButtonText: '确认',
                      cancelButtonText: '取消',
                      type: 'warning',
                    }
                ).then(() => {
                  loadingShow.value = true
                  let data = {
                    testPaper:inputData,
                    oneSelectSubjectNumber:autoDataSubject.oneSelectSubjectNumber,
                    isSelectSubjectNumber:autoDataSubject.isSelectSubjectNumber,
                    machSelectSubjectNumber:autoDataSubject.machSelectSubjectNumber,

                    testPaperPageDTO:{
                      testPaperTypeId: store.state.questionBank.subjectModel.testPaperPagination.testPaperTypeId,
                      accountTypeId: store.state.questionBank.subjectModel.testPaperPagination.accountTypeId,
                      status: store.state.questionBank.subjectModel.testPaperPagination.status,
                      pageNumber: store.state.questionBank.subjectModel.testPaperPagination.pageNum,
                      pageSize: store.state.questionBank.subjectModel.testPaperPagination.pageSize
                    }
                  }
                  //console.log("传参完成")
                  axios.post("/api/testPaper/insertTestPaper",JSON.stringify(data),{
                    headers:{
                      'Content-Type':'application/json;charset=UTF-8'
                    }
                  }).then(response => {
                    if(response.status === 200){
                      if(response.data.code === 200){
                        data.testPaperPageDTO.total = response.data.data.total
                        data.testPaperPageDTO.pageNum = store.state.questionBank.subjectModel.testPaperPagination.pageNum
                        store.commit('setTestPaperPagination', data.testPaperPageDTO)
                        store.commit('setTestPaperTableData', response.data.data.list)
                        dialogVisible.value = false
                        ElNotification({
                          title: '操作成功',
                          message: '添加成功',
                          type: 'success',
                        })
                      }else{
                        active.value = 2
                        ElNotification({
                          title: '操作失败',
                          message: '添加失败',
                          type: 'error',
                        })
                      }
                    }else{
                      active.value = 2
                      ElNotification({
                        title: '操作失败',
                        message: '添加失败',
                        type: 'error',
                      })
                    }
                  }).finally(()=>{
                    loadingShow.value = false
                  })

                })
                    .catch(() => {
                      ElNotification({
                        title: '操作异常',
                        message: '操作异常',
                        type: 'info',
                      })
                    })
              }else if(tabsNumber.value === "two"){
                ElMessageBox.confirm(
                    '确认添加?',
                    'Warning',
                    {
                      confirmButtonText: '确认',
                      cancelButtonText: '取消',
                      type: 'warning',
                    }
                ).then(() => {
                  loadingShow.value = true
                  let data = {
                    testPaper:inputData,
                    userSelectSubjectId:userSelectSubjectId.value,//题目id
                    testPaperPageDTO:{
                      testPaperTypeId: store.state.questionBank.subjectModel.testPaperPagination.testPaperTypeId,
                      accountTypeId: store.state.questionBank.subjectModel.testPaperPagination.accountTypeId,
                      status: store.state.questionBank.subjectModel.testPaperPagination.status,
                      pageNumber: store.state.questionBank.subjectModel.testPaperPagination.pageNum,
                      pageSize: store.state.questionBank.subjectModel.testPaperPagination.pageSize
                    }
                  }
                  //console.log("传参完成")
                  axios.post("/api/testPaper/insertTestPaperBySubjectListId",JSON.stringify(data),{
                    headers:{
                      'Content-Type':'application/json;charset=UTF-8'
                    }
                  }).then(response => {
                    if(response.status === 200){
                      if(response.data.code === 200){
                        data.testPaperPageDTO.total = response.data.data.total
                        data.testPaperPageDTO.pageNum = store.state.questionBank.subjectModel.testPaperPagination.pageNum
                        //console.log(data)
                        store.commit('setTestPaperPagination', data.testPaperPageDTO)
                        //console.log(store.state.questionBank.subjectModel.testPaperPagination)
                        store.commit('setTestPaperTableData', response.data.data.list)
                        dialogVisible.value = false
                        ElNotification({
                          title: '操作成功',
                          message: '添加成功',
                          type: 'success',
                        })
                      }else{
                        ElNotification({
                          title: '操作失败',
                          message: '添加失败',
                          type: 'error',
                        })
                      }
                    }else{
                      ElNotification({
                        title: '操作失败',
                        message: '添加失败',
                        type: 'error',
                      })
                    }
                  }).finally(()=>{
                    loadingShow.value = false
                  })

                })
                    .catch(() => {
                      ElNotification({
                        title: '操作异常',
                        message: '操作异常',
                        type: 'info',
                      })
                    })
              }

            }else if(active.value === 2){
              if(autoDataSubject.oneSelectSubjectNumber === 0 || autoDataSubject.isSelectSubjectNumber === 0 && autoDataSubject.machSelectSubjectNumber === 0){

                buttonIsOpen.value = true

              }else{

                buttonIsOpen.value = false
              }
            }


    }
    function getAccountTypeList(a,id){
      let arr = []
        a.forEach((val)=>{
          val.industryAccountType.forEach((vals)=>{
            vals.industryAccountType.forEach(va=>{
              va.industryAccountType.forEach(v=>{
                if(v.industryId === id){
                  arr = [val.industryName,vals.industryName,va.industryName,v.industryName]

                }
              })
            })
          })
        })
      return arr
    }

    watch(()=>inputData,(newVal)=>{
     // console.log("sfdfsf")
      if(active.value === 0){
        if(typeof newVal.testPaperTimeNumber == 'number' && typeof newVal.testPaperFraction == "number" && newVal.testPaperName !== '' && inputData.testPaperDifficulty !== 0 && inputData.testPaperTypeId !==0){
          //console.log("sfdfsf")
          buttonIsOpen.value = false
          stringshow.value = ""
        }else{
          buttonIsOpen.value = true
          stringshow.value = "请输入正确的数据格式"
        }
      }else if(active.value === 1){
          if(newVal.accountTypeId !== 0){
            buttonIsOpen.value = false
            stringshow.value = ""
          }else{
            buttonIsOpen.value = true
            stringshow.value = "请必须选择"
          }
      }
    },{
      deep:true
    })
    /*watch(()=>userSelectSubject,(newVal)=>{
      if(newVal.length === 0){
        buttonIsOpen.value = true
      }else{
        buttonIsOpen.value = false
      }
    })*/
    //************************************************
    //一键自动填充题目
    let autoDataSubject = reactive({
      autoSelectSubjectShow:false,//判断是否打开题目数量输入div
      oneSelectSubjectNumber:0,//单选题的数量
      isSelectSubjectNumber:0,//判断题数量
      machSelectSubjectNumber:0,//多选题数量
    })
    //一键选题按钮
    function autoSelectSubjectClick(){
      buttonIsOpen.value = false
      autoDataSubject.autoSelectSubjectShow = true
      mySelectedShow.value = false

    }
    //点击生成
    function readlyProduction(){
      buttonIsOpen.value = false

    }
    //手动
    function manualSelectSubjectClick(){
      axios.get("/api/subject/userSelectSubject",{
        params:{
          subjectTypeId:pageData.subjectTypeId,
          accountTypeId:inputData.accountTypeId,
          status:1,
          pageNumber:pageData.currentPage4,
          pageSize:pageData.pageSize4,
          subjectId:userSelectSubjectId.value.toString()
        }
      }).then((response)=>{
        if(response.status === 200){
          //console.log("fsfsfsf ")
          if(response.data.code === 200){
            subjectTableData.value = response.data.data.list
            pageData.subjectDataNumber = response.data.data.total
            //console.log(subjectTableData.value)
            autoDataSubject.autoSelectSubjectShow = false
            dialogVisibleShow.value = true
          }
        }
      }).finally()


    }
    //********************************************************

    let buttonIsOpen = ref(true)
    let stringshow = ref('')
    let loadingShow = ref(false)//加载

    //***********************************************************
    //手动添加题目
    let dialogVisibleShow = ref(false)//开关属性
    let subjectTableData = ref({})//题目
    let pageData = reactive({
      currentPage4:1,//页面
      pageSize4:10,//页面数量
      subjectDataNumber:0,//总条数
      subjectTypeId:0//选择题型
    })
    function dialogVisibleClose(){//关闭
        if(userSelectSubject.value.length === 0){
          buttonIsOpen.value = true
        }else{
          buttonIsOpen.value = false
        }
        dialogVisibleShow.value = false
    }
    function handleSizeChange(){//条数改变
      axios.get("/api/subject/userSelectSubject",{
        params:{
          subjectTypeId:pageData.subjectTypeId,
          accountTypeId:inputData.accountTypeId,
          status:1,
          pageNumber:1,
          pageSize:pageData.pageSize4,
          subjectId:userSelectSubjectId.value.toString()
        }
      }).then((response)=>{
        if(response.status === 200){
          //console.log("fsfsfsf ")
          if(response.data.code === 200){
            subjectTableData.value = response.data.data.list
            pageData.subjectDataNumber = response.data.data.total
            //console.log(subjectTableData.value)
            //autoDataSubject.autoSelectSubjectShow = false
            //dialogVisibleShow.value = true
          }
        }
      }).finally()
    }
    function handleCurrentChange(){//页码改变
      axios.get("/api/subject/userSelectSubject",{
        params:{
          subjectTypeId:pageData.subjectTypeId,
          accountTypeId:inputData.accountTypeId,
          status:1,
          pageNumber:pageData.currentPage4,
          pageSize:pageData.pageSize4,
          subjectId:userSelectSubjectId.value.toString()
        }
      }).then((response)=>{
        if(response.status === 200){
          //console.log("fsfsfsf ")
          if(response.data.code === 200){
            subjectTableData.value = response.data.data.list
            pageData.subjectDataNumber = response.data.data.total
            //console.log(subjectTableData.value)
            //autoDataSubject.autoSelectSubjectShow = false
            //dialogVisibleShow.value = true
          }
        }
      }).finally()
    }
    function selectSubjectTypeChange(){//选择题改变
      axios.get("/api/subject/userSelectSubject",{
        params:{
          subjectTypeId:pageData.subjectTypeId,
          accountTypeId:inputData.accountTypeId,
          status:1,
          pageNumber:pageData.currentPage4,
          pageSize:pageData.pageSize4,
          subjectId:userSelectSubjectId.value.toString()
        }
      }).then((response)=>{
        if(response.status === 200){
          //console.log("fsfsfsf ")
          if(response.data.code === 200){
            subjectTableData.value = response.data.data.list
            pageData.subjectDataNumber = response.data.data.total
            //console.log(subjectTableData.value)
            //autoDataSubject.autoSelectSubjectShow = false
            //dialogVisibleShow.value = true
          }
        }
      }).finally()
    }
    let userSelectSubject = ref([])//记录用户选择的
    let userSelectSubjectId = ref([])
    //用户添加
    function userSelectClick(a){
      userSelectSubject.value.push(a)
      userSelectSubjectId.value.push(a.subjectId)
      axios.get("/api/subject/userSelectSubject",{
        params:{
          subjectTypeId:pageData.subjectTypeId,
          accountTypeId:inputData.accountTypeId,
          status:1,
          pageNumber:pageData.currentPage4,
          pageSize:pageData.pageSize4,
          subjectId:userSelectSubjectId.value.toString()
        }
      }).then((response)=>{
        if(response.status === 200){
          //console.log("fsfsfsf ")
          if(response.data.code === 200){
            subjectTableData.value = response.data.data.list
            pageData.subjectDataNumber = response.data.data.total
            console.log(subjectTableData.value)
            //autoDataSubject.autoSelectSubjectShow = false
            //dialogVisibleShow.value = true
          }
        }
      }).finally()
      //console.log(userSelectSubject.value)
    }
    //用户查看选择的题目
    let dialogVisibleUserSelectSubjectShow = ref(false)//已选题目弹出层
    function dialogVisibleUserSelectSubjectClose(){//关闭弹出层方法
     // console.log("fssd")
      axios.get("/api/subject/userSelectSubject",{
        params:{
          subjectTypeId:pageData.subjectTypeId,
          accountTypeId:inputData.accountTypeId,
          status:1,
          pageNumber:1,
          pageSize:pageData.pageSize4,
          subjectId:userSelectSubjectId.value.toString()
        }
      }).then((response)=>{
        if(response.status === 200){
          //console.log("fsfsfsf ")
          if(response.data.code === 200){
            subjectTableData.value = response.data.data.list
            pageData.subjectDataNumber = response.data.data.total
            //console.log(subjectTableData.value)
            //autoDataSubject.autoSelectSubjectShow = false
            //dialogVisibleShow.value = true
          }
        }
      }).finally()
      dialogVisibleUserSelectSubjectShow.value = false
    }
    let userSelectSubjectTableData = ref([])//该弹出层表格数据
    function userDelClick(a){//移除选择的题目
      userSelectSubjectTableData.value = userSelectSubjectTableData.value.filter(v=>v.subjectId !== a.subjectId)
      userSelectSubject.value = userSelectSubject.value.filter(v=>v.subjectId !== a.subjectId)
      userSelectSubjectId.value = userSelectSubjectId.value.filter(v=>v!==a.subjectId)
    }
    function openUserSelectSubjectDig(a){//打开用户选择的题目弹出层的方法
      if(a === 1){
        userSelectSubjectTableData.value = userSelectSubject.value.filter(v=>v.subjectTypeId === 1)
      }else if(a === 2){
        userSelectSubjectTableData.value = userSelectSubject.value.filter(v=>v.subjectTypeId === 2)
      }else if(a === 3){
        userSelectSubjectTableData.value = userSelectSubject.value.filter(v=>v.subjectTypeId === 3)
      }
      dialogVisibleUserSelectSubjectShow.value = true
    }
    function confirmSelectedSubject(){//用户确认亦轩的题目
      dialogVisibleShow.value = false
      mySelectedShow.value = true
    }
    let mySelectedShow = ref(false)//手动选择的最终结果div
    let tabsNumber = ref('');//标签页
    function tabClick(a){
      if(a.props.name === "two"){
        if(userSelectSubject.value.length === 0){
          buttonIsOpen.value = true
        }else{
          buttonIsOpen.value = false
        }
        manualSelectSubjectClick()
      }else{
        buttonIsOpen.value = false
      }
    }
    return {
      mySelectedShow,
      tabsNumber,
      userSelectSubject,
      confirmSelectedSubject,
      tabClick,
      userDelClick,
      dialogVisibleUserSelectSubjectShow,
      userSelectSubjectTableData,
      userSelectClick,
      openUserSelectSubjectDig,
      dialogVisibleUserSelectSubjectClose,
      handleCurrentChange,
      handleSizeChange,
      selectSubjectTypeChange,
      pageData,
      subjectTableData,
      stringshow,
      dialogVisibleClose,
      dialogVisibleShow,
      buttonIsOpen,
      autoDataSubject,
      dialogVisible,
      active,
      loadingShow,
      manualSelectSubjectClick,
      addTestPaperClick,
      closeDislogVidble,
      autoSelectSubjectClick,
      readlyProduction,
      back,
      next,
      treeComponent,
      store,
      inputData,
      nowTime,
      ArrowLeft,
      ArrowRight,
      oneTableData,

      selectArr
    }
  }
}
</script>

<style scoped>
</style>